﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FALibrary.Part;
using System.Reflection;

namespace FAFramework.Manager
{
    public class PartManager
    {
        public FAPart aPart = null;
        public void LoadFromFile(string filename)
        {
            XElement xml = null;
            
            xml = XElement.Load(filename);

            foreach (XElement item in xml.Elements())
            {
                string name = item.Element("Name").Value.Trim();
                string partType = item.Element("PartType").Value.Trim();
                string description = item.Element("Description").Value.Trim();

                Assembly assembly = Assembly.Load("FALibrary");
                Type type = System.Type.GetType("FALibrary.Part." + partType);
                object obj = assembly.CreateInstance("FALibrary.Part." + partType);                
                FAPart part =  obj as FAPart;
                part.Description = description;
                aPart = part;
            }
        }
    }
}
